package com.zhoukx.command;

/**
 * @ClassName Invoker
 * @Description:  m命令设计模式，通过遥控器对电灯的操作
 * @Author zhoukx
 * @Date 2020/8/17
 **/
public class Client {

    public static void main(String[] args) {
        // 使用命令模式完成遥控，对电灯操作
        LightReceiver lightReceiver = new LightReceiver();
        // 创建电灯相关的开关
        LightOnCommand lightOnCommand = new LightOnCommand(lightReceiver);
        LightOffCommand lightOffCommand = new LightOffCommand(lightReceiver);

        // 需要一个遥控器
        RemoteController remoteController = new RemoteController();
        // 给我们遥控器设置相关的命令  比如no =0 是电灯的开和关
        remoteController.setCommand(0,lightOnCommand,lightOffCommand);
        remoteController.onButtonWasPused(0);
        remoteController.offButtonWasPused(0);
        remoteController.undoButtonWasPushed();

        System.out.println("----------------操作电视----------------");
        TVReveiver tvReveiver = new TVReveiver();
        TVOffCommand tvOffCommand = new TVOffCommand(tvReveiver);
        RemoteController remoteController1 = new RemoteController();
        remoteController.setCommand(0,tvOffCommand,tvOffCommand);
        remoteController.onButtonWasPused(0);
        remoteController.offButtonWasPused(0);
    }
}
